package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * 采购流程规则配置
 *
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-23
 */
@Entity
@Table(schema = "public", name = "ord_purchase_process", indexes = {@Index(name = "ord_purchase_process_member_id_idx", columnList = "memberId"), @Index(name = "ord_purchase_process_role_id_idx", columnList = "roleId"), @Index(name = "ord_purchase_process_base_purchase_process_id_idx", columnList = "base_purchase_process_id"), @Index(name = "ord_purchase_process_name_idx", columnList = "name"), @Index(name = "ord_purchase_process_create_time_idx", columnList = "createTime"), @Index(name = "ord_purchase_process_process_type_idx", columnList = "processType")})
public class OrderPurchaseProcessDO implements Serializable {
    private static final long serialVersionUID = 509660445577071473L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_purchase_process_seq")
    @SequenceGenerator(sequenceName = "ord_purchase_process_seq", name = "ord_purchase_process_seq", allocationSize = 1)
    private Long id;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime createTime;

    /**
     * 会员Id
     */
    @Column
    private Long memberId;

    /**
     * 会员角色Id
     */
    @Column
    private Long roleId;

    /**
     * 规则名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String name;

    /**
     * 流程的Key
     */
    @Column(columnDefinition = "varchar(100)")
    private String processKey;

    /**
     * 流程类型，定义在 OrderPurchaseProcessTypeEnum 中
     */
    @Column
    private Integer processType;

    /**
     * 流程类别，定义在 WorkflowProcessKindEnum 中， 1-内部流程，2-外部流程，3-复杂流程
     */
    @Column
    private Integer processKind;

    /**
     * 启动流程后，是否跳过第一个步骤
     */
    @Column
    private Boolean skipFirstStep;

    /**
     * 是否包含所有合同
     */
    @Column
    private Boolean allContracts;

    /**
     * 状态，0-停用，1-启用
     */
    @Column
    private Integer status;

    /**
     * 多对一单向关联基础采购流程
     */
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "base_purchase_process_id")
    private BasePurchaseProcessDO basePurchaseProcess;

    /**
     * 一对多双向关联合同设置
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "process", cascade = {CascadeType.DETACH, CascadeType.REMOVE}, fetch = FetchType.LAZY)
    private Set<OrderPurchaseProcessContractDO> contracts;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getProcessKey() {
        return processKey;
    }

    public void setProcessKey(String processKey) {
        this.processKey = processKey;
    }

    public Integer getProcessType() {
        return processType;
    }

    public void setProcessType(Integer processType) {
        this.processType = processType;
    }

    public Integer getProcessKind() {
        return processKind;
    }

    public void setProcessKind(Integer processKind) {
        this.processKind = processKind;
    }

    public Boolean getSkipFirstStep() {
        return skipFirstStep;
    }

    public void setSkipFirstStep(Boolean skipFirstStep) {
        this.skipFirstStep = skipFirstStep;
    }

    public Boolean getAllContracts() {
        return allContracts;
    }

    public void setAllContracts(Boolean allContracts) {
        this.allContracts = allContracts;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public BasePurchaseProcessDO getBasePurchaseProcess() {
        return basePurchaseProcess;
    }

    public void setBasePurchaseProcess(BasePurchaseProcessDO basePurchaseProcess) {
        this.basePurchaseProcess = basePurchaseProcess;
    }

    public Set<OrderPurchaseProcessContractDO> getContracts() {
        return contracts;
    }

    public void setContracts(Set<OrderPurchaseProcessContractDO> contracts) {
        this.contracts = contracts;
    }
}
